package aes.general;

import java.io.IOException;
import aes.gui.TeacherQuestionPanel;


/**
 * The Class QuestionControl.
 */
public class QuestionControl {
	
	private static boolean qstrec ;
	private static TeacherQuestionPanel Qp;
	

	/**
	 * Instantiates a new question control.
	 *
	 * @param qp the qp
	 */
	public QuestionControl(TeacherQuestionPanel qp) {
		super();
		this.Qp = qp;
	}



	/**
	 * Adds the questionr request to server.
	 *
	 * @param newuqst the newuqst
	 */
	public void AddQuestionrRequestToServer(Question newuqst) {

		try {
			GuiControlBeta.getClient().openConnection();
		} catch (IOException e) {
			
			e.printStackTrace();
		}

		Msg request = new Msg(newuqst, "400");
		GuiControlBeta.getClient().handleMessageFromClientUI(request);
	}

	
	
	/**
	 * Question requestfrom client.
	 *
	 * @param msg the msg
	 */
	public static void QuestionRequestfromClient(Object msg){
		String rep;
		rep = (String)((Msg) msg).getMsg();
		if(rep.equals("Error")){
			qstrec = false;
		}
		else if(rep.equals("Ok")){
			qstrec = true;
		}			
	}
	
	
	
	public static boolean isQstrec() {
		return qstrec;
	}



	/**
	 * Gets the request.
	 *
	 * @return the request
	 */
	public boolean getRequest()
	{
		return qstrec;
		
	}

}
